package org.example.exception;

import lombok.Data;
import org.example.enums.BizCodeEnum;

/**
 * @description: 业务异常状态类
 * @author: 谢超
 * @date: 2023/07/15 23:18
 **/
@Data
public class BizException extends RuntimeException{
    /**
     * 错误码
     */
    private int code;

    /**
     * 错误信息
     */
    private String msg;

    /*构造函数*/
    public BizException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
    }
}
